#include <iostream>
#include <vector>
#include <Vector.hpp>

using namespace std;

class Solution
{
public:
    vector<vector<int>> combine(int n, int k)
    {
        vector<vector<int>> result;
        vector<int> path;
        backTrack(1, n, k, path, result);
        return result;
    }

    void backTrack(int start, int end, int countRelease, vector<int> &path, vector<vector<int>> &result)
    {
        if (countRelease <= 1)
        {
            for (int i = start; i <= end; i++)
            {
                result.push_back(path);
                result.back().push_back(i);
            }
            return;
        }
        for (int i = start; i <= end; i++)
        {
            path.push_back(i);
            backTrack(i + 1, end, countRelease - 1, path, result);
            path.pop_back();
        }
    }
};

int main()
{
    cout << "Code77" << endl;
    Solution s;
    vector<vector<int>> result = s.combine(4, 2);
    Print2DVector(result);
    return 0;
}